package com.ks.BusAlarm;

import android.app.Activity;
import android.content.Intent;
import android.speech.tts.TextToSpeech;

public class TTS extends Activity {
	private static final int MY_DATA_CHECK_CODE = 4321;
	private TextToSpeech mTts;
	String message;

	void startTTSActivity() {

		// Intent checkIntent = new Intent();
		// checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);

		// Activity activity = new Activity();
		// activity.startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);

		// startActivity(checkIntent);
		// startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);

	}

	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == MY_DATA_CHECK_CODE) {
			if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {

				// success, create the TTS instance
				play();

			} else {
				// missing data, install it
				Intent installIntent = new Intent();
				installIntent
						.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
				startActivity(installIntent);
			}
		}
	}

	private void play() {

		mTts.speak(message, TextToSpeech.QUEUE_FLUSH, null);
	}

}
